/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package nueva.esperanza.modelo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author mgcharuc
 */
@Entity
@Table(name = "BANCO",schema = "SYS")
@SequenceGenerator(name="seqBanco", sequenceName="SYSTEM.BANCO_SEQ")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Banco.findAll", query = "SELECT b FROM Banco b"),
    @NamedQuery(name = "Banco.findByIdbanco", query = "SELECT b FROM Banco b WHERE b.idbanco = :idbanco"),
    @NamedQuery(name = "Banco.findByNombrebanco", query = "SELECT b FROM Banco b WHERE b.nombrebanco = :nombrebanco")})
public class Banco implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @GeneratedValue(generator = "seqBanco")
    @Column(name = "IDBANCO")
    private BigDecimal idbanco;
    @Column(name = "NOMBREBANCO")
    private String nombrebanco;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idbanco", fetch = FetchType.LAZY)
    private List<Cuenta> cuentaList;

    public Banco() {
    }

    public Banco(BigDecimal idbanco) {
        this.idbanco = idbanco;
    }

    public BigDecimal getIdbanco() {
        return idbanco;
    }

    public void setIdbanco(BigDecimal idbanco) {
        this.idbanco = idbanco;
    }

    public String getNombrebanco() {
        return nombrebanco;
    }

    public void setNombrebanco(String nombrebanco) {
        this.nombrebanco = nombrebanco;
    }

    @XmlTransient
    public List<Cuenta> getCuentaList() {
        return cuentaList;
    }

    public void setCuentaList(List<Cuenta> cuentaList) {
        this.cuentaList = cuentaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idbanco != null ? idbanco.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Banco)) {
            return false;
        }
        Banco other = (Banco) object;
        if ((this.idbanco == null && other.idbanco != null) || (this.idbanco != null && !this.idbanco.equals(other.idbanco))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "nueva.esperanza.modelo.Banco[ idbanco=" + idbanco + " ]";
    }
    
}
